home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / lblcs.arc / CRT_320S.ASM next >
Assembly Source File  |  1985-04-05  |  3KB  |  133 lines

  1. ;------------------------------------------------------------------
  2. ; name        crt_ps320sg 
  3. ;
  4. ; synopsis    crt_ps320sg(segment, offset, row, col, color)
  5. ;        int    segment;    /* 0xb000=mono    0xb800=color    */
  6. ;        int    offset;        /* use 0 for graphics adaptor    */
  7. ;        int    row;        /*  row number 0 to 199        */
  8. ;        int    col;        /*  col number 0 to 399        */
  9. ;        int    color;        /*  color      0 to 3        */
  10. ;
  11. ; description    This subroutine sets a point on the 320 x 200
  12. ;        graphics screen.  Hand coded in assembly, It
  13. ;        operates 8 - 10 times faster than the corres-
  14. ;        ponding BIOS call.  
  15. ;
  16. ; notes        This routine will treat any passed segment value 
  17. ;        like an interlaced graphics adaptor.  It could 
  18. ;        just as well be a block of memory that has been
  19. ;        allocated, (i.e. a graphics buffer that is to be moved
  20. ;        to the screen after a group of points are set ),
  21. ;        or some other segment value for a non-PC compatible
  22. ;        display.  If you are addressing the display adaptors,
  23. ;        use an offst of 0.  If you are handling a buffer, use
  24. ;        the buffers segment and offset.  Large model pointers
  25. ;        must be broken into segment and offset which are 
  26. ;        passed separately.  
  27. ;        
  28. ;        This routine handles graphics interlacing 
  29. ;        (normal IBM PC graphics).  It would not function
  30. ;        on a machine that does not interlace graphics -
  31. ;        i.e. the Tandy T2000.
  32. ;
  33. ;        If you pass the correct segment value based on the 
  34. ;        equipment flag setting, this routine will work on
  35. ;        both a color and mono display adaptor.
  36. ;         
  37. ; bugs        row, col, and color are not validated - make sure
  38. ;        they are in range or you could crash the system. 
  39. ;
  40. ;-------------------------------------------------------------------
  41.  
  42.     include    dos.mac
  43.  
  44.     IF    LPROG
  45. X    EQU    6        ;OFFSET OF ARGUMENTS
  46.     ELSE
  47. X    EQU    4        ;OFFSET OF ARGUMENTS
  48.     ENDIF
  49.  
  50.     PSEG
  51.  
  52.     PUBLIC    crt_ps320sg
  53.  
  54.     IF    LPROG
  55. crt_ps320sg    PROC    FAR
  56.     ELSE
  57. crt_ps320sg    PROC    NEAR
  58.     ENDIF
  59.  
  60. SEGM    equ    x+2
  61. OFS    equ    x+4
  62. COL    equ    x+6
  63. ROW    equ    x+8
  64. COLR    equ    x+10
  65.  
  66.  
  67.     push    bp
  68.     push    es
  69.     mov    bp,sp
  70.     mov    ax,[bp+SEGM]
  71.     mov    es,ax        ; set es to color video segment
  72.  
  73.     mov    ax,[bp+ROW]    ; get row
  74.     mov    cx,[bp+COL]    ; get columnm
  75.     mov    dl,[bp+CoLR]    ; get color
  76.  
  77.     
  78.     and    ax,0feh        ; strip odd/even bit of Y (row)
  79.  
  80.     sal    ax,1
  81.     sal    ax,1
  82.  
  83.     sal    ax,1        ; ax = ax * 8
  84.     mov    bx,ax        ; bx = ax * 8
  85.  
  86.     sal    ax,1        ; ax = ax * 16
  87.     sal    ax,1        ; ax = ax * 32
  88.  
  89.     add    ax,bx        ; ax = ax * 40
  90.     mov    bx,[bp+ROW]
  91.     sar    bx,1        ; low bit into carry
  92.     jnb    even        ; if low bit 0, y is even
  93.     add    ax,02000h    ; adjust for odd y - other video ram bank
  94.  
  95. even:
  96.     sar    cx,1        
  97.     sar    cx,1        ; cx = x / 4
  98.     add    ax,cx        ; ax has final address
  99.     mov    cx,[bp+OFS]
  100.     add    ax,cx        ; add in offset value
  101.     mov    si,ax        
  102.     mov    cx,[bp+COL]
  103. ; now determine the bit to set
  104.     and    cx,0003h    ; cx = x mod 4
  105.  
  106.     clc            ; clear carry
  107.     rcr    dl,1        ; move color bit to cary
  108.     rcr    dl,1        ; move color bit to bit 7 of dl
  109.     rcr    dl,1        ; move color bits to 7,6
  110.     mov    al,0c0h        ; start with 1100000b
  111.  
  112.     add    cl,cl        ; cl = cl * 2
  113.     shr    al,cl        ; shift bit to right position
  114.     shr    dl,cl    
  115.  
  116.     not    al        ; do 1's complement
  117.     and    al,es:[si]    ; mask the right bit
  118.     or    al,dl        ; or in the color bit
  119.  
  120.     mov    es:[si],al    ; put back on screen
  121.  
  122.     pop    es
  123.     pop    bp        ; restore registers
  124.     ret
  125.  
  126. crt_ps320sg    endp
  127.  
  128.     ENDPS    
  129.     END
  130.  
  131.  
  132.  
  133.